{% extends 'base.html' %}

{% block title %}
    问答详情-{{question.title}}
{% endblock title %}

{% block head %}
    <link rel="stylesheet" href="{{ url_for('static', filename='css/detail.css') }}">
{% endblock head %}

{% block content %}
    <div class="row" style="margin-top: 25px;">
        <div class="col-1"></div> 
        <!-- padding 内边距 -->
        <div class="col-10" style="background-color: #fff; padding: 20px;">
            <h3 class="page-title">{{ question.title }}</h3>
            <p class="question-info">
                <span>作者: {{ question.author.username }}</span>
                <span>时间: {{ question.create_time }}</span>
            </p>
            <hr>
            <p class="question-content">
                {{ question.content }}
            </p>
            <hr>

            <p>评论({{ question.answers | length }}):</p>
            <form method="post" action="{{ url_for('qa.answer', question_id=question.id) }}">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="请填写评论" name="content">
                </div>
                <div class="form-group">
                    {% for  msg in  get_flashed_messages() %} 
                        <div class="alert alert-info alert-dismissible fade show" role="alert">
                            <strong>Tips:</strong> 
                            {{msg}}
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>  
                    {% endfor %}
                </div>
                <div class="form-group text-right">
                    <button class="btn btn-primary" type="submit" >评论</button>
                </div>
            </form>
            <hr>

            <ul class="list-group">
                {% for answer in question.answers %}
                    <li class="list-group-item list-group-item-action">
                        <div class="d-flex w-100 justify-content-between">
                        <h5 class="mb-1">{{ answer.author.username }}</h5>
                        <small class="text-muted">{{ answer.create_time }}</small>
                        </div>
                        <p class="mb-1">{{ answer.content }}</p>
                        <small class="text-muted">And some muted small print.</small>
                    </li>
                {% endfor %}
            </ul>
        </div>
        <div class="col-1"></div>
    </div>
{% endblock content %}